package com.karst.essentials.chapter02
{
	import com.karst.essentials.chapter02.inherit.InheritClass;
	
	import flash.display.Sprite;
	
	public class Chapter02View extends Sprite
	{
		public static const SECTION_LIST : Array = 
			["类-ExampleClass", "继承-InheritClass", "第一个应用-FirstApplication",
			 "PV3D基础视图-BasicViewExample", "代码模板-BookExampleTemplate"] ;
		
		public function Chapter02View()
		{
			super();
		}
		
		
		public function showSection( $section : String = "" ) : void
		{
			while( numChildren )
				removeChildAt( 0 ) ;
			switch( $section )
			{
				case SECTION_LIST[0] :
					createExampleClass() ;
					break ;
				case SECTION_LIST[1] :
					createInheritClass() ;
					break ;
				case SECTION_LIST[2] :
					createFirstApplication() ;
					break ;
				case SECTION_LIST[3] :
					createBasicViewExample() ;
					break ;
				case SECTION_LIST[4] :
					createBookExampleTemplate() ;
					break ;
				default :
					break ;
			}
		}

		private var exampleClass : ExampleClass = null ;
		private function createExampleClass() : void
		{
			if( exampleClass == null )
				exampleClass = new ExampleClass() ;
			exampleClass.traceName() ;
			exampleClass.myName = "karst.xia" ;
			exampleClass.traceName() ;
		}

		private var inheritClass : InheritClass = null ;
		private function createInheritClass() : void
		{
			if( inheritClass == null )
				inheritClass = new InheritClass() ;
		}

		private var firstApplication : FirstApplication = null ;
		private function createFirstApplication() : void
		{
			if( firstApplication == null )
				firstApplication = new FirstApplication() ;
			addChild( firstApplication ) ;
		}

		private var basicViewExample : BasicViewExample = null ;
		private function createBasicViewExample() : void
		{
			if( basicViewExample == null )
				basicViewExample = new BasicViewExample() ;
			addChild( basicViewExample ) ;
		}

		private var bookExampleTemplate : BookExampleTemplate = null ;
		private function createBookExampleTemplate() : void
		{
			if( bookExampleTemplate == null )
				bookExampleTemplate = new BookExampleTemplate() ;
			addChild( bookExampleTemplate ) ;
		}
	}
}